/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.report.accounting;

import java.util.List;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import src.domain.gl.Glbalance;

/**
 *
 * @author Lalugina
 */
public class RptGlbalanceDS implements JRDataSource{
    private int index = -1;
    private List<Glbalance> glbalances;

    public RptGlbalanceDS(List<Glbalance> glbalances) {
        super();
        this.glbalances = glbalances;
    }

    @Override
    public boolean next() throws JRException {
        index++;
        return (index < glbalances.size());
    }

    @Override
    public Object getFieldValue(JRField jrf) throws JRException {
        Object value = null;

	String fieldName = jrf.getName();
        switch (fieldName) {
            case "accountNo": value = glbalances.get(index).getAccountNo(); break;
            case "accountName": value = glbalances.get(index).getAccountName(); break;
            case "accountType": value = glbalances.get(index).getAccountType(); break;
            case "awal": value = glbalances.get(index).getAwal(); break;
            case "saldo": value = glbalances.get(index).getSaldo(); break;
            case "total": value = glbalances.get(index).getTotal(); break;
            case "total01": value = glbalances.get(index).getTotal01(); break;
            case "total02": value = glbalances.get(index).getTotal02(); break;
            case "total03": value = glbalances.get(index).getTotal03(); break;
            case "total04": value = glbalances.get(index).getTotal04(); break;
            case "total05": value = glbalances.get(index).getTotal05(); break;
            case "total06": value = glbalances.get(index).getTotal06(); break;
            case "total07": value = glbalances.get(index).getTotal07(); break;
            case "total08": value = glbalances.get(index).getTotal08(); break;
            case "total09": value = glbalances.get(index).getTotal09(); break;
            case "total10": value = glbalances.get(index).getTotal10(); break;
            case "total11": value = glbalances.get(index).getTotal11(); break;
            case "total12": value = glbalances.get(index).getTotal12(); break;
        }
	return value;
    }
    
}
